package com.wd.tech.view.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.wd.tech.R;
import com.wd.tech.bean.PlateLieBiao;
import com.wd.tech.bean.ZixunBean;
import com.wd.tech.mvp.base.BaseActivity;
import com.wd.tech.mvp.base.BasePresenter;
import com.wd.tech.mvp.presenter.PresenterImpl;
import com.wd.tech.mvp.util.MyUrl;
import com.wd.tech.view.adapter.PlateLieBiaoAdapter;
import com.wd.tech.view.adapter.ZixunAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;

//所有模块列表Activity
public class PlateLieBiaoActivity extends BaseActivity implements View.OnClickListener {

    @BindView(R.id.bt_left)
    Button btLeft;
    @BindView(R.id.btPd_sousuo)
    Button btPdSousuo;
    @BindView(R.id.rvPd)
    RecyclerView rvPd;
    @BindView(R.id.tv_name)
    TextView tvName;
    private int id;
    private int plateId;

    @Override
    protected void startCoding() {
        //根据id展示对应名字的列表
        id = getIntent().getIntExtra("id", 0);
        plateId = getIntent().getIntExtra("plateId", 0);
        //名字那块
        String techName1 = getIntent().getStringExtra("techName");
        //设置
        this.tvName.setText(techName1);



            Map map=new HashMap();
            map.put("plateId",id);
            map.put("page",1);
            map.put("count",10);
            mPresenter.startgetInofHava(MyUrl.zixunliebiao,PlateLieBiao.class,map);


    }

    @Override
    protected BasePresenter initPresenter() {
        return new PresenterImpl();
    }

    @Override
    protected void initView() {
        LinearLayoutManager manager = new LinearLayoutManager(this);
        manager.setOrientation(RecyclerView.VERTICAL);
        rvPd.setLayoutManager(manager);
        //点击返回 从列表返回到所有模块Activity
        btLeft.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(PlateLieBiaoActivity.this,PlateActivity.class);
                startActivity(intent);
                finish();
            }
        });

        //搜索
        btPdSousuo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });



    }

    @Override
    protected int Layout() {
        return R.layout.activity_zi_xun_detail;
    }

    @Override
    public void onClick(View v) {

    }

    @Override
    public void onSuccess(Object o) {
        if (o instanceof PlateLieBiao){

            PlateLieBiaoAdapter plateLieBiaoAdapter=new PlateLieBiaoAdapter(this,((PlateLieBiao) o).getResult());
            rvPd.setAdapter(plateLieBiaoAdapter);


            //Toast.makeText(this, ""+((PlateLieBiao) o).getMessage(), Toast.LENGTH_SHORT).show();
        }

    }

    @Override
    public void onError(String error) {
        Toast.makeText(this, ""+error, Toast.LENGTH_SHORT).show();
    }



}
